#ifndef __IM_OBJECT_QUEUE_H__
#define __IM_OBJECT_QUEUE_H__

#include <im_base_types.h>
#include <im_object.h>

/**
 * @defgroup IMObjectQueue
 * @ingroup PrivateIMBusIME
 * @{
 */

/** @struct IMObjectQueue
 *  @brief An queue to hold one or more objects.
 *
 * This class is a container which can hold one or more objects.
 */

IM_BEGIN_DECLS

#define IM_OBJECT_QUEUE(p)           (IM_TYPE_INSTANCE_CHECK_CAST((p),IM_TYPE_OBJECT_QUEUE,IMObjectQueue))
#define IM_CONST_OBJECT_QUEUE(p)     (IM_TYPE_INSTANCE_CHECK_CAST_CONST((p),IM_TYPE_OBJECT_QUEUE,IMObjectQueue))
#define IM_OBJECT_QUEUE_CLASS(c)     (IM_TYPE_CLASS_CHECK_CAST((c),IM_TYPE_OBJECT_QUEUE,IMObjectQueueClass))
#define IM_IS_OBJECT_QUEUE(p)        (IM_TYPE_INSTANCE_CHECK_TYPE((p),IM_TYPE_OBJECT_QUEUE))
#define IM_IS_OBJECT_QUEUE_CLASS(c)  (IM_TYPE_CLASS_CHECK_TYPE((c),IM_TYPE_OBJECT_QUEUE))
#define IM_OBJECT_QUEUE_GET_CLASS(p) (IM_TYPE_INSTANCE_GET_CLASS_CAST((p),IM_TYPE_OBJECT_QUEUE,IMObjectQueueClass))

typedef struct _IMObjectQueue        IMObjectQueue;
typedef struct _IMObjectQueueClass   IMObjectQueueClass;

/**
 * @brief Create a new IMObjectQueue object.
 */
IMObjectQueue*  im_object_queue_new             ();
/**
 * @brief Clear an IMObjectQueue object.
 *
 * All objects in it will be unreferenced.
 */
void            im_object_queue_clear           (IMObjectQueue          *queue);
/**
 * @brief Get number of objects stored in an IMObjectQueue object.
 */
IMSize          im_object_queue_length          (const IMObjectQueue    *queue);
/**
 * @brief Get first object in the queue.
 */
IMPointer       im_object_queue_front           (const IMObjectQueue    *queue);
/**
 * @brief Get last object in the queue.
 */
IMPointer       im_object_queue_back            (const IMObjectQueue    *queue);
/**
 * @brief Add an object to the head of the queue.
 */
void            im_object_queue_push_front      (IMObjectQueue          *queue,
                                                 IMPointer               object);
/**
 * @brief Add an object to the end of the queue.
 */
void            im_object_queue_push_back       (IMObjectQueue          *queue,
                                                 IMPointer               object);
/**
 * @brief Remove an object from the head of the queue.
 *
 * The removed object will not be returned,
 * Call im_object_queue_front() or im_object_queue_back() to get it first.
 */
void            im_object_queue_pop_front       (IMObjectQueue          *queue);
/**
 * @brief Remove an object from the end of the queue.
 *
 * The removed object will not be returned,
 * Call im_object_queue_front() or im_object_queue_back() to get it first.
 */
void            im_object_queue_pop_back        (IMObjectQueue          *queue);

IM_END_DECLS
/** @} */

#endif
/*
vi:ts=4:nowrap:ai:expandtab
*/
